﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<List<MensUnoShop.Models.OrderData>>" %>
<%@ Import Namespace="MvcPaging"%>  
<%@ Import Namespace="MensUnoShop.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	OrderListReturning
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" language="javascript">
    function changeorderretrun(oguid, tostatus) {
        var jsonstring = { "oguid": oguid, "orderstatus": tostatus };
        $.ajax({
            type: "POST",
            traditional: true,
            url: "/Admin/OrderManagement/OrderStatusChange",
            data: jsonstring,
            dataType: "json",
            success: function (data) {
                if (data.code == "200") {
                    alert("狀態變更成功!");
                    location.href = 'OrderListReturning?page=0';
                    //$("#tr_" + oguid).remove();
                }
                else
                    alert(data.response);
                //location.reload();
            }
        });
    }

    
</script>

 <div id="main-content" class="hastable">
    <div class="title title-spacing">
        <h2>退貨清單</h2>
	</div>
    <%using (Html.BeginForm("OrderListReturning", "OrderManagement", FormMethod.Post, new { @class = "shBox" }))
    {%>      
      起始時間<input type="text" id="Text1" name="sdate" class="datepicker" value="<%:ViewData["sdate"] %>"/>
      結束時間<input type="text" id="Text2" name="edate" class="datepicker" value="<%:ViewData["edate"] %>"/>
      <button type="submit" class="button">查詢</button>
    <%} %>
    <table cellspacing="0">
        <thead>
	        <tr>
                <td style="width:100px">訂單編號</td>
                <td style="width:100px">退貨日期</td>
                <td style="width:100px">收件人姓名</td>
                <td style="width:100px">收件人電話</td>
                <td style="width:100px">收件人地址</td>
                <td style="width:100px">商品貨號</td>
                <td style="width:100px">商品名稱</td>
                <td style="width:100px">退貨狀態</td>
                <td style="width:100px"></td>
                <td style="width:50px"></td>
                <td style="width:50px"></td>
			</tr>
		</thead>
        <%if (Model != null)
            {%>           
        <tbody>
            <%foreach (var item in Model)
            {  %>
        	<tr>             
                <td><%:item.OTXID %></td>
                <td><%:item.OSTATUSDATEIN.GetValueOrDefault().ToString("yyyy/MM/dd HH:mm:ss")%></td>
                <td><%:item.RCNAME %></td>
                <td><%:item.RCTEL %></td>
                <td><%:item.RCCOUNTRY %><%:item.RCZIP %><%:item.RCCITY %><%:item.RCAREA %><%:item.RCADDRESS %></td>
                <td><%:item.MOKSN %></td>
                <td><%:item.MOKTITLE %></td>
                <td><%=Html.GetOrderStatus((MensUnoShop.Models.Config.OrderStatusType)item.OSTATUS)%></td>
                <td>
                <%if ((MensUnoShop.Models.Config.OrderStatusType)item.OSTATUS == MensUnoShop.Models.Config.OrderStatusType.ApplyReturn)
                  {%>
                <input type="button" name="changeorderrefunding" id="changeorderrefunding" value="待退款" onclick="javascript:changeorderretrun('<%:item.OGUID %>','4');" />
                <input type="button" name="cancelorderreturn" id="cancelorderreturn" value="取消退貨" onclick="javascript:changeorderretrun('<%:item.OGUID %>','8');" />
                <%}
                  else if ((MensUnoShop.Models.Config.OrderStatusType)item.OSTATUS == MensUnoShop.Models.Config.OrderStatusType.Refunding)
                  {%>
                <input type="button" name="changeorderrefunded" id="changeorderrefunded" value="退貨完成" onclick="javascript:changeorderretrun('<%:item.OGUID %>','5');" />
                <%}%>
                </td>
                <td><a id="OrderDetail" name="OrderDetail" class="iframe" target="_blank" href="OrderDetailView/<%:item.OGUID %>">訂單明細</a></td>
                <td><a id="MemberDetail" name="MemberDetail" class="iframe" target="_blank" href="../MemberManagement/MemberDetailView/<%:item.MGUID %>">會員資料</a></td>                
            </tr>
            <%} %>
        </tbody>
        <%} %>    
    </table>
    <br/><br/>　
</div>


<script type="text/javascript">
        $("a#OrderDetail").fancybox({ width: 810 });
        $("a#MemberDetail").fancybox({ height: 400, scrolling: 'no' });
</script>

</asp:Content>

